package com.tengju.bff.infrastructure.export.repo;

import com.tengju.bff.infrastructure.export.convert.BillServiceSignConvert;
import com.tengju.bff.interfaces.covercharge.entity.vo.ServiceSignQuery;
import com.tengju.bff.interfaces.covercharge.service.IServiceSignService;
import com.tengju.bff.interfaces.shared.export.BillServiceSignExportQuery;
import com.tengju.export.domain.record.ExportDataSourceRepository;
import com.tengju.export.domain.record.Query;
import com.tengju.export.domain.record.Table;
import com.tengju.user.application.user.UserDataAuthService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: 李大仙
 * @date: 2021/8/23 2:39 下午
 */
@Service("billServiceSignExportDataSourceRepository")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class BillServiceSignExportDataSourceRepository implements ExportDataSourceRepository {

    private final IServiceSignService serviceSignService;
    private final UserDataAuthService userDataAuthService;

    @Override
    public Table batchFindDataSource(Query query) {
        BillServiceSignExportQuery exportQuery = (BillServiceSignExportQuery) query;

        List<ServiceSignQuery> dataList = serviceSignService.queryByPageExport(exportQuery.getSigningTime(),
                exportQuery.getIdCode(),
                exportQuery.getMobile(),
                exportQuery.getUserName(),
                exportQuery.getPlatformCode(),
                exportQuery.getSignName(),
                exportQuery.getIdNumberIdNumber(),
                exportQuery.getStatus(),
                exportQuery.getSubStatus(),
                exportQuery.getMethodCooperation());

        //对数据做脱敏处理
        dataList = userDataAuthService.dataMasking(dataList, exportQuery.getStaffId());

        return BillServiceSignConvert.convert(dataList);
    }
}
